Repository navigation
feat: collection permalinks, step 1 — the contract and one entry path function - #72
Merged
Merged
Conversation
… function
RFC-0038 / ADR-0040, step 1 (no behaviour change):
- Contract: `Site.collections.<key>.permalink`, a template with a closed
token set; v1 accepts fixed segments plus `/{slug}`. Fixtures: one valid,
three invalid (trailing slash, unknown token, no slug). TS and Rust
regenerated.
- core-ts `permalinks.ts`: `entryPath(site, entry)`, `entryAt(site, path)`,
`collectionPermalink`, `permalinkPrefix`; browser-safe subpath
`@cloudhal/core-ts/permalinks`.
- Every entry URL (about 35 inline `/${collection}/${slug}` copies and the
renderer's one-argument `entryPath`) now comes from them: renderer
routes, SEO, feeds, previews, surfaces, navigation, comments; starter;
core-ts automations, search, the store's automatic redirect; API assets,
menus, search, comments; MCP analytics, comments, search, schedules; CLI
analytics; Studio screens through `EntryPath` / `useSitePermalinks`.
- The renderer's `resolvePath` reads entries through `entryAt`.
- Themes without a Site get the templates through `MediaContext.permalinks`.
With no `collections` set every path is unchanged.
Refs #50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC-0038 / ADR-0040, step 1 of 3. There is no behaviour change: with no
collectionsset, every entry URL is exactly what it was. Refs #50.Contract
Site.collections.<key>.permalink: a template with a closed token set; v1 is fixed lower-case segments plus/{slug}(schema pattern).valid/site/collection-permalinks.json;invalid/site/permalink-{trailing-slash,unknown-token,without-slug}.json. TS and Rust regenerated.One function each way (
@cloudhal/core-ts, browser-safe./permalinkssubpath)entryPath(site, entry)andentryAt(site, path)(longest configured prefix first; a moved collection no longer answers at its old prefix), pluscollectionPermalinkandpermalinkPrefix.Every caller moved
About 35 inline
/${collection}/${slug}copies and the renderer's one-argumententryPath(entry):resolvePath(now throughentryAt), SEO, feeds, previews, surfaces, navigation, comments;release-titles.tssplit out for the size ratchet);EntryPath/useSitePermalinksand the slug field prefix.Themes without a
Sitein hand get the templates throughMediaContext.permalinks.A few callers that had only a site id now read the site once (in parallel where possible):
releaseView,commentEntries, CLIpublishedNodes, andplanSearch(it reads the site node once).Checks (run per package, sequentially)
permalinks.test.ts)Also passing: Rust tests, clippy, typecheck everywhere, design lint, and the size ratchet (the baseline only went down).
Next steps
hrefs when a template changes.set_collection_permalinktool (with approval).🤖 Generated with Claude Code